In [2]:
import numpy as np
In [4]:
ones_arr=np.ones((5,5),dtype=int)
ones_arr
Out[4]:
array([[1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1]])
In [5]:
ones_arr * 255
Out[5]:
array([[255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255]])
In [78]:
import matplotlib.pyplot as plt
In [8]:
matplotlib inline #all graph should keep inside the line
In [9]:
from PIL import Image   #python image library
In [28]:
horse_img=Image.open(r"C:\Anitha\image\pexels-wildlittlethingsphoto-1996333.jpg")
horse_img
Out[28]:
No description has been provided for this image
In [80]:
type(horse_img)
Out[80]:
PIL.JpegImagePlugin.JpegImageFile
In [41]:
horse_arr=np.asarray(horse_img)
horse_arr
Out[41]:
array([[[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [25, 37, 35],
        [19, 34, 31],
        [14, 30, 27]],

       [[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [26, 38, 36],
        [22, 37, 34],
        [20, 36, 33]],

       [[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [28, 40, 38],
        [25, 40, 37],
        [24, 40, 37]],

       ...,

       [[49, 50, 44],
        [40, 41, 35],
        [35, 35, 27],
        ...,
        [14, 30, 29],
        [13, 25, 25],
        [12, 22, 23]],

       [[45, 50, 44],
        [38, 43, 37],
        [31, 36, 30],
        ...,
        [11, 25, 25],
        [12, 24, 24],
        [16, 26, 27]],

       [[31, 41, 33],
        [31, 41, 33],
        [32, 39, 32],
        ...,
        [14, 26, 26],
        [16, 26, 27],
        [23, 31, 33]]], dtype=uint8)
In [81]:
type(horse_arr)
Out[81]:
numpy.ndarray
In [42]:
plt.imshow(horse_arr)
Out[42]:
<matplotlib.image.AxesImage at 0x1436e1614c0>
In [43]:
plt.show()
No description has been provided for this image
In [82]:
horse_arr.shape
Out[82]:
(2334, 3502, 3)
In [44]:
horse_arr=type(horse_img)
horse_arr
Out[44]:
PIL.JpegImagePlugin.JpegImageFile
In [83]:
horse_red=horse_arr.copy()
horse_red
Out[83]:
array([[[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [25, 37, 35],
        [19, 34, 31],
        [14, 30, 27]],

       [[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [26, 38, 36],
        [22, 37, 34],
        [20, 36, 33]],

       [[15, 17, 29],
        [15, 17, 29],
        [15, 17, 29],
        ...,
        [28, 40, 38],
        [25, 40, 37],
        [24, 40, 37]],

       ...,

       [[49, 50, 44],
        [40, 41, 35],
        [35, 35, 27],
        ...,
        [14, 30, 29],
        [13, 25, 25],
        [12, 22, 23]],

       [[45, 50, 44],
        [38, 43, 37],
        [31, 36, 30],
        ...,
        [11, 25, 25],
        [12, 24, 24],
        [16, 26, 27]],

       [[31, 41, 33],
        [31, 41, 33],
        [32, 39, 32],
        ...,
        [14, 26, 26],
        [16, 26, 27],
        [23, 31, 33]]], dtype=uint8)
In [84]:
#horse_arr=np.asarray(horse_img)
#horse_arr

horse_arr==horse_red
Out[84]:
array([[[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]],

       [[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]],

       [[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]],

       ...,

       [[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]],

       [[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]],

       [[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True],
        ...,
        [ True,  True,  True],
        [ True,  True,  True],
        [ True,  True,  True]]])
In [90]:
plt.imshow(horse_red)
Out[90]:
<matplotlib.image.AxesImage at 0x1436de2dc40>
In [91]:
plt.show()
No description has been provided for this image
In [92]:
plt.imshow(horse_red[:,:,0])
Out[92]:
<matplotlib.image.AxesImage at 0x1436e160620>
In [93]:
plt.show()
No description has been provided for this image
In [94]:
horse_red[:,:,0]
Out[94]:
array([[15, 15, 15, ..., 25, 19, 14],
       [15, 15, 15, ..., 26, 22, 20],
       [15, 15, 15, ..., 28, 25, 24],
       ...,
       [49, 40, 35, ..., 14, 13, 12],
       [45, 38, 31, ..., 11, 12, 16],
       [31, 31, 32, ..., 14, 16, 23]], dtype=uint8)
In [76]:
plt.imshow(horse_red[:,:,0],cmap='Greys')
Out[76]:
<matplotlib.image.AxesImage at 0x1436e259970>
In [77]:
plt.show()
No description has been provided for this image
In [95]:
plt.imshow(horse_red[:,:,1],cmap='grey')
Out[95]:
<matplotlib.image.AxesImage at 0x1436df66780>
In [96]:
plt.show()
No description has been provided for this image
In [99]:
plt.imshow(horse_red[:,:,1],cmap='YlOrBr')
Out[99]:
<matplotlib.image.AxesImage at 0x1436fb95dc0>
In [100]:
plt.show()
No description has been provided for this image
In [101]:
plt.imshow(horse_red[:,:,2],cmap='YlGn')
Out[101]:
<matplotlib.image.AxesImage at 0x1436fb964e0>
In [102]:
plt.show()
No description has been provided for this image
In [ ]:
 
In [104]:
ones_arr=np.ones((5,5),dtype=int)
ones_arr
Out[104]:
array([[1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1]])
In [105]:
ones_arr*255
Out[105]:
array([[255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255]])
In [107]:
pic=Image.open(r"C:\Anitha\Data Science1\Main screen.png")
In [108]:
pic
Out[108]:
No description has been provided for this image
In [109]:
type(pic)
Out[109]:
PIL.PngImagePlugin.PngImageFile
In [110]:
pic_arr=np.asarray(pic)
pic_arr
Out[110]:
array([[[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       [[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       [[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       ...,

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 14,  14,  14, 255],
        [ 14,  14,  14, 255],
        [ 14,  14,  14, 255]],

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 13,  13,  13, 255],
        [ 13,  13,  13, 255],
        [ 13,  13,  13, 255]],

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 12,  12,  12, 255],
        [ 12,  12,  12, 255],
        [ 12,  12,  12, 255]]], dtype=uint8)
In [111]:
type(pic_arr)
Out[111]:
numpy.ndarray
In [112]:
plt.imshow(pic_arr)
Out[112]:
<matplotlib.image.AxesImage at 0x1436fef8950>
In [113]:
plt.show()
No description has been provided for this image
In [116]:
pic_arr.shape
Out[116]:
(624, 1207, 4)
In [118]:
pic_red=pic_arr.copy()
pic_red
Out[118]:
array([[[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       [[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       [[ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        [ 12,  11,   4, 255],
        ...,
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255],
        [ 34,  34,  34, 255]],

       ...,

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 14,  14,  14, 255],
        [ 14,  14,  14, 255],
        [ 14,  14,  14, 255]],

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 13,  13,  13, 255],
        [ 13,  13,  13, 255],
        [ 13,  13,  13, 255]],

       [[ 10,  16,  19, 255],
        [ 11,  16,  21, 255],
        [ 13,  17,  23, 255],
        ...,
        [ 12,  12,  12, 255],
        [ 12,  12,  12, 255],
        [ 12,  12,  12, 255]]], dtype=uint8)
In [119]:
pic_red==pic_arr
Out[119]:
array([[[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]],

       [[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]],

       [[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]],

       ...,

       [[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]],

       [[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]],

       [[ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        ...,
        [ True,  True,  True,  True],
        [ True,  True,  True,  True],
        [ True,  True,  True,  True]]])
In [120]:
plt.imshow(pic_red)
Out[120]:
<matplotlib.image.AxesImage at 0x1436e2a2f30>
In [122]:
plt.show()
No description has been provided for this image
In [123]:
pic_red.shape
Out[123]:
(624, 1207, 4)
In [124]:
plt.imshow(pic_red[:,:,0])
Out[124]:
<matplotlib.image.AxesImage at 0x1436ffae540>
In [125]:
plt.show()
No description has been provided for this image
In [126]:
pic_red[:,:,0]
Out[126]:
array([[12, 12, 12, ..., 34, 34, 34],
       [12, 12, 12, ..., 34, 34, 34],
       [12, 12, 12, ..., 34, 34, 34],
       ...,
       [10, 11, 13, ..., 14, 14, 14],
       [10, 11, 13, ..., 13, 13, 13],
       [10, 11, 13, ..., 12, 12, 12]], dtype=uint8)
In [131]:
plt.imshow(pic_red[:,:,0],cmap='YlGnBu')
Out[131]:
<matplotlib.image.AxesImage at 0x14305e35b50>
In [132]:
plt.show()
No description has been provided for this image
In [145]:
plt.imshow(pic_red[:,:,2], cmap='BuPu')
Out[145]:
<matplotlib.image.AxesImage at 0x14305639640>
In [146]:
plt.show()
No description has been provided for this image
In [139]:
plt.imshow(pic_red[:,:,2], cmap='YlGn')
Out[139]:
<matplotlib.image.AxesImage at 0x143063d6780>
In [140]:
plt.show()
No description has been provided for this image
In [143]:
plt.imshow(pic_red[:,:,2], cmap='Reds')
Out[143]:
<matplotlib.image.AxesImage at 0x1430645d580>
In [144]:
plt.show()
No description has been provided for this image
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: